package d2_buffered_stream;

import java.io.*;

/**
 * 2024/6/18 掌握字节缓冲流的作用 Cjj 11:51
 */
public class BufferedInputStream_Test1 {
    public static void main(String[] args) {
        try (
            InputStream is= new FileInputStream("file-io2\\src\\test\\InputStream");
             //1.定义一个字节缓冲输入流包装原始的字节输入流
            InputStream bis = new BufferedInputStream(is);

            OutputStream os = new FileOutputStream("file-io2\\src\\test\\InputStream_01");
            //2.定义一个字节缓存输出流包装原始的字节输出流
            OutputStream bos =new BufferedOutputStream(os);
        ){
            byte[] buffer = new byte[1024];
            int len;
            while ((len = bis.read(buffer))!=-1){
                 bos.write(buffer,0,len);
            }
            System.out.println("复制完成");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

